﻿using System;
using Viettel.VOFFICE.DAO.Helpers;
using Viettel.VOFFICE.DAO.Models;
using System.ComponentModel.DataAnnotations;
using Viettel.VOFFICE.DAO.Enums;


namespace Viettel.VOFFICE.Web.Models
{
    public class DocumentPropertyModel : BaseModel
    {
        public int Id { get; set; }

        [Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "region")]
        public string Name { get; set; }

        [Required(ErrorMessageResourceType = typeof(Resources.Resources), ErrorMessageResourceName = "region")]
        public byte Type { get; set; }
        public bool? IsActive { get; set; }
        public bool? IsDefault { get; set; }
        public DateTime CreatedAt { get; set; }
        public DateTime UpdatedAt { get; set; }
        public Guid? CreatorId { get; set; }
        public string TypeName { get; set; }
      
        public DocumentPropertyModel()
        {
            IsDefault = true;
            IsActive = false;
            CreatedAt = DateTime.Now;
            UpdatedAt = DateTime.Now;
        }
        public DocumentPropertyModel(DocumentProperty documentProperty)
        {
            Id = documentProperty.Id;
            Name = documentProperty.Name;
            Type = documentProperty.Type;
            IsActive = documentProperty.IsActive;
            IsDefault = documentProperty.IsDefault;
            CreatedAt = documentProperty.CreatedAt;
            UpdatedAt = documentProperty.UpdatedAt;
            CreatorId = documentProperty.CreatorId;
            TypeName = EnumHelper<DocPropertyType>.GetStringValue((DocPropertyType) documentProperty.Type);
        }
    }
}